//
//  ZXZNavViewController.swift
//  up_learnWB
//
//  Created by Mac on 16/10/20.
//  Copyright © 2016年 www.ZXZ123.com. All rights reserved.
//

import UIKit

class ZXZNavViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBar.isHidden = true;

    }


    @objc private func comeBackClick(){
        self.popViewController(animated: true)
    }

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            if let vc = viewController as? ZXZBaseViewController {

                if viewControllers.count == 1{
                    vc.navItem.leftBarButtonItem =  UIBarButtonItem(title: viewControllers.first?.title ?? "返回", fontSize: 16, target: self, action: #selector(ZXZNavViewController.comeBackClick))
                }else{

                    vc.navItem.leftBarButtonItem =  UIBarButtonItem(title: "返回", fontSize: 16, target: self, action: #selector(ZXZNavViewController.comeBackClick), isBack:true)
                }
            }

        }
        super.pushViewController(viewController, animated: true)
    }
    
    
}
